// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import axios from "axios";
import VueAxios from "vue-axios"
import qs from 'qs'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

//设置请求的根路径
axios.defaults.baseURL = "http://localhost:8081/"

Vue.config.productionTip = false

Vue.use(axios, VueAxios)
Vue.use(ElementUI)

Vue.prototype.$http = axios
Vue.prototype.$qs = qs


axios.interceptors.request.use(config => {
  // 请求后台接口需加上token，存储在sessionStorage中
  var token = window.sessionStorage.getItem('token');
  if (token != null) {
    config.headers.Authorization = token
  }
  return config
})

new Vue({
  el: '#app',
  render: h => h(App),
  components: {App},
  template: '<App/>'
})
